let fs = require("fs");
let path = require("path");

let target = [];
function searchDeepSync(array, _filepath, ext) {
    let files = fs.readdirSync(_filepath, "utf-8");
    // console.log(files);
    files.forEach(value => {
        let folder = path.join(_filepath, value);
        // console.log(folder);
        let slats = fs.statSync(folder);
        if (slats.isDirectory()) {
            searchDeepSync(array, folder, ext);
        } else {
            if (value.endsWith(ext)) {
                array.push(value);
            }
        }
    });

}

searchDeepSync(target, __dirname, "js");
console.log(target);